<!DOCTYPE html>
<meta charset='utf-8'>
<title>Window Placement: isMultiScreen() tentative</title>
<!-- TODO: update link to W3C whenever specifications are ready -->
<link rel='help' href='https://github.com/webscreens/window-placement'/>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script src='resources/screenenumeration-helpers.js'></script>
<script>

'use strict';

screen_enumeration_test(async (t, mockScreenEnum) => {
  let display1 = makeDisplay(10,
                             {x: 0, y: 0, width: 800, height: 600},
                             {x: 0, y: 0, width: 800, height: 550},
                             1.0);

  let display2 = makeDisplay(11,
                             {x: 800, y: 0, width: 800, height: 600},
                             {x: 800, y: 0, width: 800, height: 550},
                             2.0);

  mockScreenEnum.setSuccess(true);
  assert_equals(await self.isMultiScreen(), false);

  mockScreenEnum.addDisplay(display1);
  assert_equals(await self.isMultiScreen(), false);

  mockScreenEnum.addDisplay(display2);
  assert_equals(await self.isMultiScreen(), true);

  mockScreenEnum.removeDisplay(display2.id);
  assert_equals(await self.isMultiScreen(), false);
}, 'isMultiScreen() works as expected with mocked screens');

screen_enumeration_test(async (t, mockScreenEnum) => {
  mockScreenEnum.setSuccess(false);
  promise_rejects_dom(t, 'NotAllowedError', self.isMultiScreen());
}, 'isMultiScreen() rejects when the mock success value is set to false');

</script>
